﻿Public Class Restauracion

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Verificador._FechaRestauracion = Me.DateTimePicker1.Value.Date
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
    Private Sub LeerRespeldo()
        Verificador.DSvalesVendidos.Leidos.Rows.Clear()
        DsAdmingas.Leidos.Clear()
        DsAdmingas.Leidos.Rows.Clear()
        Dim _RutaResp As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & " \Verificador de vales\"
        If IO.File.Exists(_RutaResp & "\" & Format(DateTimePicker1.Value, "dd-MM-yyyy") & ".xml") = False Then
            LtotalDia.Text = " Hay 0 vales en la fecha Seleccionada"
            Return
        End If
        Try
            Verificador.DSvalesVendidos.Leidos.ReadXml(Verificador._RutaResp & "\" & Format(DateTimePicker1.Value, "dd-MM-yyyy") & ".xml")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Dim _Total = Verificador.DSvalesVendidos.Leidos.Rows.Count '.Select("fechaleido='" & DateTimePicker1.Value.Date & "'").Count
        LtotalDia.Text = " Hay " & _Total & " vales en la fecha Seleccionada"
        Button1.Enabled = IIf(_Total > 0, True, False)
    End Sub

    Private Sub DateTimePicker1_TextChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.TextChanged

    End Sub
    Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
        LeerRespeldo()
    End Sub

    Private Sub Restauracion_Load(sender As Object, e As EventArgs) Handles Me.Load
        Me.DateTimePicker1.Value = Now.Date
    End Sub
End Class